package com.example.lib_patrol.detail

import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.viewbinding.ViewBinding
import com.alibaba.android.arouter.facade.annotation.Route
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.listener.OnItemClickListener
import com.example.lib_common.mvi.BaseActivity
import com.example.lib_patrol.PatrolRowEntity
import com.example.lib_patrol.databinding.ActivityPatrolDetailBinding
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.uuzuche.lib_zxing.activity.ZXingLibrary

@Route(path = "/patrol/DetailActivity")
class DetailActivity : BaseActivity<ActivityPatrolDetailBinding,DetailViewModel>() {
    override fun createVM(): DetailViewModel {
        return DetailViewModel()
    }

    override fun createViewBinding(): ViewBinding {
       return ActivityPatrolDetailBinding.inflate(inflater)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val pPoint = intent.getStringExtra("pPoint")
        val type =object : TypeToken<List<PatrolRowEntity>>() {}.type
        val fromGson= Gson().fromJson(pPoint,type) as ArrayList<PatrolRowEntity>
        v.backBtn.setOnClickListener { finish() }
        val adapter = DetailAdapter()
        val layoutManager = LinearLayoutManager(this)
        layoutManager.orientation= LinearLayoutManager.VERTICAL
        v.detailRecycler.layoutManager=layoutManager
        v.detailRecycler.adapter=adapter
        adapter.setNewInstance(fromGson)
        adapter.setOnItemClickListener { adapter, view, position ->

        }
    }
}